package com.ruoyi.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

/*
流程启动实例
流程实例---流程定义的一个实例
 */
public class ActivitiStartInstance {
    public static void main(String[] args) {
        System.out.println(".....开始启动流程实例.....");
        //1.得到ProcessEngine对象
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();
        //2.得到RunService对象
        RuntimeService runtimeService = defaultProcessEngine.getRuntimeService();
        //3.创建流程实例
        //myProcess_1
        //3.创建流程实例,同时要添加业务标识BusinessKey(第二个参数)，假设请假单的id是10001，第二个参数就是用于将流程表 跟我们自己的业务表产生关联
        ProcessInstance holiday = runtimeService.startProcessInstanceByKey("myProcess_1","1200");//""holiday");
        //4.输出流程实例的相关信息
        System.out.println("部署ID："+holiday.getDeploymentId());
        System.out.println("名称："+holiday.getName());
        System.out.println("ID："+holiday.getId());
        System.out.println("业务KEY："+holiday.getBusinessKey());
        System.out.println("实例ID："+holiday.getActivityId());
    }
}
